<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../tpl/head.jsp"%>
<form class="layui-form layui-from-pane" style="padding:20px">
  <div class="layui-form-item">
    <label class="layui-form-label">箱子名称</label>
    <div class="layui-input-block">
      <input type="text" name="title"  autocomplete="off" placeholder="请输入标题" class="layui-input" id="boxname">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">主题匹配</label>
    <div class="layui-input-block">
      <input type="radio" name="sub" value="模糊" title="模糊匹配" checked="checked">
      <input type="radio" name="sub" value="精准" title="精准匹配">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">主题</label>
    <div class="layui-input-block">
      <input type="text" name="title"  autocomplete="off" placeholder="请输入标题" class="layui-input" id="subject">
    </div>
  </div>
   <div class="layui-form-item">
    <label class="layui-form-label">标签</label>
    <div class="layui-input-block">
      <input type="text" name="title"  autocomplete="off" placeholder="请输入标题" class="layui-input" id="tag">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">收件人</label>
    <div class="layui-input-block">
      <input type="text" name="title"  autocomplete="off" placeholder="请输入标题" class="layui-input" id="recipientName">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">收件人地址</label>
    <div class="layui-input-block">
      <input type="text" name="title"  autocomplete="off" placeholder="请输入标题" class="layui-input" id="recipientAddress">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">收件时间</label>
    <div class="layui-input-block">
      <input type="text" class="layui-input" id="recDate" placeholder=" - ">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">发件人</label>
    <div class="layui-input-block">
      <input type="text" name="title"  autocomplete="off" placeholder="请输入标题" class="layui-input" id="addresser">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">发件人地址</label>
    <div class="layui-input-block">
      <input type="text" name="title"  autocomplete="off" placeholder="请输入标题" class="layui-input" id="senderAddresser">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">发件时间</label>
    <div class="layui-input-block">
      <input type="text" class="layui-input" id="sendDate" placeholder=" - ">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">附件</label>
    <div class="layui-input-block">
      <input type="radio" name="sex" value="不限" title="不限" checked="checked">
      <input type="radio" name="sex" value="含附件" title="含附件">
      <input type="radio" name="sex" value="不含附件" title="不含附件">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">附件标题</label>
    <div class="layui-input-block">
      <input type="text" name="title"  autocomplete="off" placeholder="请输入标题" class="layui-input" id="adjunct">
    </div>
  </div>
</form>
<%@ include file="../../tpl/foot.jsp"%>
<script>
  var boxid=null;
  var search_id=null;
layui.use('laydate', function(){
	var laydate = layui.laydate;
	laydate.render({
	    elem: '#recDate'
	    ,type: 'datetime'
        ,trigger:'click'
	    ,range: true
	  });
  laydate.render({
    elem: '#sendDate'
    ,type: 'datetime'
    ,trigger:'click'
    ,range: true
  });
});
var callbackdata = function () {
  var data = {
    "box_id":boxid,
    "search_id":search_id,
    "boxname":$("#boxname").val(),
    "subject":$("#subject").val(),
    "tag":$("#tag").val(),
    "recipientName":$("#recipientName").val(),
    "recipientAddress":$("#recipientAddress").val(),
    "recDate":$("#recDate").val(),
    "addresser":$("#addresser").val(),
    "senderAddresser":$("#senderAddresser").val(),
    "sendDate":$("#sendDate").val(),
    "isAdjunct":$("input[name='sex']:checked").val(),
    "adjunct":$("#adjunct").val(),
    "sub":$("input[name='sub']:checked").val()
  };
  return data;
}

$(document).ready(function () {

  boxid=GetQueryString("boxid");
  $.ajax({
    url: 'email/selectBoxById',
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: false,
    data: {
      "box_id":boxid
    },
    success: function (date) {
     var boxName = date.data.box_name;
      $("#boxname").val(boxName)
      search_id=date.data.select_rule;
    },
});
  $.ajax({
    url: 'email/selectSearchById',
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    data: {
      "search_id":search_id
    },
    success: function (date) {
     var search = date.data;
      $("#subject").val(search.subject);
      $("#tag").val(search.tag);
      $("#recipientName").val(search.recipientName);
      $("#recipientAddress").val(search.recipientAddress);
      $("#recDate").val(search.recDateStart+" - "+search.recDateEnd);
      $("#addresser").val(search.addresser);
      $("#senderAddresser").val(search.senderAddresser);
      $("#sendDate").val(search.sendDateStart+" - "+search.sendDateEnd);
      $("#adjunct").val(search.adjunct);
              if(search.isAdjunct==1){
                $("input[name='sex']:checked").val("含附件");
              }else if(search.isAdjunct==0){
                $("input[name='sex']:checked").val("不含附件");
              }

    },
  });
})
  //获取url中的值
  function GetQueryString(name) {

    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);  //获取url中"?"符后的字符串并正则匹配
    var context = "";
    if (r != null)
      context = r[2];
    reg = null;
    r = null;
    return context == null || context == "" || context == "undefined" ? "" : context;
  }
</script>